package com.nursing.Dao;
import com.nursing.bean.Admin;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AdminDao {
    @Select("SELECT * FROM admin")
    List<Admin> getAll();

    @Select("SELECT * FROM admin WHERE id = #{id}")
    Admin getById(Integer id);

    @Insert("INSERT INTO admin (username, password) VALUES (#{username}, #{password})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(Admin admin);

    @Update("UPDATE admin SET username = #{username}, password = #{password} WHERE id = #{id}")
    void update(Admin admin);

    @Delete("DELETE FROM admin WHERE id = #{id}")
    void delete(Integer id);

    @Select("SELECT * FROM admin WHERE username = #{username} AND password = #{password}")
    Admin verify(String username, String password);

    @Update("UPDATE admin SET password = #{password} WHERE id = #{id}")
    void changePassword(Admin admin);
}
